Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@stacks/common
Advanced tools
@stacks/common is a utility library that provides a set of common functions and utilities used across the Stacks ecosystem. It includes functions for data manipulation, encoding/decoding, and other helper utilities that facilitate development within the Stacks blockchain environment.
Data Encoding/Decoding
This feature provides utilities for encoding and decoding data, such as converting strings to byte arrays and vice versa. This is useful for handling data in a format suitable for blockchain transactions.
const { utf8ToBytes, bytesToUtf8 } = require('@stacks/common');
const text = 'Hello, Stacks!';
const bytes = utf8ToBytes(text);
console.log(bytes); // Uint8Array of byte values
const decodedText = bytesToUtf8(bytes);
console.log(decodedText); // 'Hello, Stacks!'
Hex Encoding/Decoding
This feature allows for conversion between hexadecimal strings and byte arrays, which is essential for handling cryptographic data and transaction payloads in blockchain applications.
const { hexToBytes, bytesToHex } = require('@stacks/common');
const hexString = '48656c6c6f';
const bytes = hexToBytes(hexString);
console.log(bytes); // Uint8Array of byte values
const hex = bytesToHex(bytes);
console.log(hex); // '48656c6c6f'
Buffer Utilities
This feature provides utilities for working with buffers, such as concatenating multiple byte arrays. This is useful for constructing data payloads that need to be sent over the network or stored on the blockchain.
const { concatBytes } = require('@stacks/common');
const buffer1 = new Uint8Array([1, 2, 3]);
const buffer2 = new Uint8Array([4, 5, 6]);
const combined = concatBytes(buffer1, buffer2);
console.log(combined); // Uint8Array [1, 2, 3, 4, 5, 6]
The 'buffer' package is a Node.js core module that provides a way of handling binary data. It offers similar functionalities for encoding/decoding and manipulating byte arrays. While 'buffer' is more general-purpose and widely used across various Node.js applications, @stacks/common is tailored specifically for the Stacks blockchain ecosystem.
The 'crypto-js' package provides a variety of cryptographic algorithms for JavaScript. It includes utilities for encoding/decoding and hashing, similar to some of the functionalities in @stacks/common. However, 'crypto-js' is more focused on cryptographic operations, whereas @stacks/common includes additional utilities specific to blockchain data handling.
Common utilities used by Stacks.js packages.
npm install @stacks/common
FAQs
Common Stacks utilities
We found that @stacks/common demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.